﻿//-------------------------------------------------------------------
//	Copyright (c) 2010-2014  Zhirnov Andrey
//	This file is part of the "UX Standard Lib" project.
//	See copyright notice in "UX_STL_Ext.h".
//-------------------------------------------------------------------

#ifndef _UXS_WINDOW_EVENTS_H
#define _UXS_WINDOW_EVENTS_H

#pragma once

namespace UX_STL
{
namespace _platform_
{
	class CWindow;
}

namespace UXTypesExt
{
	using namespace UXTypesExt;



	//
	// Event
	//

	struct TWindowEvent
	{
		//
		// Key Event
		//

		struct TKeyEvent
		{
			uint16			eKey;
			wchar			wChar;
			char			cChar;
			bool			bPressed;
		};


		//
		// Mouse Key Event
		//

		struct TMouseKeyEvent
		{
			int		iDeltaWheel;
			bool	bButton1Changed : 1,
					bButton1Pressed : 1,
				
					bButton2Changed : 1,
					bButton2Pressed : 1,
				
					bButton3Changed : 1,
					bButton3Pressed : 1,
				
					bButton4Changed : 1,
					bButton4Pressed : 1,
				
					bButton5Changed : 1,
					bButton5Pressed : 1;
		};


		//
		// Mouse Event
		//

		struct TMouseEvent
		{
			int		iX,
					iY;
			bool	bDelta;	// delta or absolute
		};


		//
		// Message
		//

		struct TMessage
		{
			enum EWindowMsg
			{
				UNKNOWN		= 0,
				PAUSE,		// WM_KILLFOCUS
				RESUME,		// WM_SETFOCUS
				RESIZE,		// WM_SIZE
				MINIMIZED,	// SIZE_MINIMIZED
				MAXIMIZED,	// SIZE_MAXIMIZED
				MOVE,		// WM_MOVE
				DESTROY,	// WM_DESTROY
			};

			EWindowMsg	eMsg;
		};


		//
		// User Event
		//

		struct TUserEvent
		{
			usize	iParam1,
					iParam2;
		};


		// variables
		e_wnd_event::type	eEventType;
		union
		{
			TKeyEvent			sKey;
			TMouseKeyEvent		sMouseKey;
			TMouseEvent			sMouse;
			TMessage			sMsg;
			TUserEvent			sUser;
		}
		sEvent;
		///
		TWindowEvent(): eEventType(e_wnd_event::UNKNOWN) {}
	};
	

	//
	// Window Event Listener
	//

	class IWindowEventListener
	{
	public:
		virtual void ProcessMessage (const TWindowEvent &sEvent) = 0;
	};


	//
	// Window Updater
	//

	class IWindowUpdater
	{
	public:
		virtual void OnUpdate (_platform_::CWindow *) = 0;
	};

//-------------------------------------------------------------------

}	// UXTypesExt
}	// UX_STL

#endif	// _UXS_WINDOW_EVENTS_H